﻿package view.tips
{
    import __AS3__.vec.*;
    import com.core.destroy.*;
    import com.sh.game.util.*;
    import consts.*;
    import flash.display.*;
    import flash.text.*;
    import morn.core.components.*;
    import plugin.component.*;
    import pluginfw.*;

    public class TaskTips extends Sprite
    {
        private var _container:Sprite;
        private var _rewSprite:Sprite;
        private var _effContainer:Sprite;
        private var bkImage:BitmapScale9Grid;
        private var line:Bitmap;
        private var line1:Bitmap;
        private var nametxt:Label;
        private var _followMouse:Boolean;
        private var bHeight:int = 60;
        private var cfgtask:Object;
        private var cfgitem:Object;
        private var cfgMoster:Object;
        private var cfgnpcs:Object;
        private var cfgNpc:Object;
        private var goalTypeArr:Array;
        private var itemList:Vector.<FlashItem>;
        private var format1:TextFormat;
        private var format2:TextFormat;
        private var format3:TextFormat;
        private var nametxt1:Label;
        private var msg1:String;
        private var msg2:String;
        private var rcTips:Label;

        public function TaskTips()
        {
            this.cfgtask = ConfigDictionary.data.task;
            this.cfgitem = ConfigDictionary.data.item;
            this.cfgMoster = ConfigDictionary.data.monster;
            this.cfgnpcs = ConfigDictionary.data.sysnpc;
            this.cfgNpc = ConfigDictionary.data.npc;
            this.goalTypeArr = new Array("", "击杀", "击杀", "使用", "采集", "解救美女", "击杀精英怪", "击杀玩家", "自身死亡", "等级提升", "拥有{0}", "拥有{0}级装备", "装备{0}", "装备{0}级装备", "通关{0}");
            this.format1 = new TextFormat("宋体", 14);
            this.format2 = new TextFormat("宋体", 12);
            this.format3 = new TextFormat("宋体", 12, null);
            this.itemList = new Vector.<FlashItem>;
            this.init();
            this.mouseChildren = false;
            this.mouseEnabled = false;
            return;
        }// end function

        public function showImage(param1:Bitmap, param2:Bitmap, param3:Bitmap) : void
        {
            this.bkImage = new BitmapScale9Grid(param1, 10, 16, 10, 29);
            this.bkImage.visible = false;
            this.bkImage.width = 290;
            this._container.addChildAt(this.bkImage, 0);
            this.line = new Bitmap(param3.bitmapData);
            this.line.x = 14;
            this.line.y = this.bHeight - 5;
            this.line.width = 262;
            this._container.addChild(this.line);
            this.line1 = new Bitmap(param3.bitmapData);
            this.line1.x = 14;
            this.line1.y = 221;
            this.line1.width = 262;
            this._container.addChild(this.line1);
            return;
        }// end function

        private function init() : void
        {
            this._container = new Sprite();
            this.addChild(this._container);
            this._effContainer = new Sprite();
            this.addChild(this._effContainer);
            this._rewSprite = new Sprite();
            this.addChild(this._rewSprite);
            this._rewSprite.y = this.bHeight;
            this.nametxt = new Label();
            this.nametxt.width = 70;
            this.nametxt.text = "【目标】：";
            this.nametxt.x = 26;
            this.nametxt.y = 26;
            this.nametxt.color = 12361057;
            this.nametxt.stroke = "0x0";
            this.nametxt.align = "left";
            this.nametxt.isHtml = true;
            this._container.addChild(this.nametxt);
            this.nametxt1 = new Label();
            this.nametxt1.width = 180;
            this.nametxt1.text = "";
            this.nametxt1.x = 86;
            this.nametxt1.y = 26;
            this.nametxt1.stroke = "0x0";
            this.nametxt1.align = "left";
            this.nametxt1.isHtml = true;
            this.nametxt1.color = MColor.New65;
            this._container.addChild(this.nametxt1);
            this.rcTips = new Label();
            this.rcTips.text = "次日登录降妖伏魔任务次数重置";
            this.rcTips.x = 45;
            this.rcTips.y = 220;
            this.rcTips.color = MColor.New52;
            this.rcTips.stroke = "0x0";
            this.rcTips.align = "left";
            this.rcTips.isHtml = true;
            this._container.addChild(this.rcTips);
            this.rcTips.visible = false;
            this.mouseEnabled = false;
            return;
        }// end function

        public function set data(param1:Object) : void
        {
            var _loc_2:Object = null;
            var _loc_3:FlashItem = null;
            var _loc_4:Label = null;
            var _loc_15:FlashItem = null;
            var _loc_16:Label = null;
            var _loc_17:Label = null;
            var _loc_18:Label = null;
            while (this.itemList.length > 0)
            {
                
                _loc_15 = this.itemList.shift();
                if (_loc_15)
                {
                    if (_loc_15.parent)
                    {
                        _loc_15.parent.removeChild(_loc_15);
                    }
                    _loc_15.dispose();
                    _loc_15 = null;
                }
            }
            var _loc_5:* = UserData.getUserData("career");
            var _loc_6:* = UserData.getUserData("sex");
            DestroyUtil.removeChildren(this._rewSprite);
            var _loc_7:int = 20;
            var _loc_8:* = UserData.getData(UserDataType.Task);
            if (UserData.getData(UserDataType.Task) == null)
            {
                return;
            }
            if (int(param1.cfg.taskid) == 0)
            {
                return;
            }
            var _loc_9:* = int(_loc_8["tid_" + param1.cfg.taskid].state);
            if (int(_loc_8["tid_" + param1.cfg.taskid].state) == 1)
            {
                this.addreciveHtml(param1.cfg, "fnpc");
            }
            else if (_loc_9 == 2)
            {
                this.addreciveHtml(param1.cfg, "goal");
            }
            else
            {
                this.addreciveHtml(param1.cfg, "tnpc");
            }
            this.nametxt1.text = this.msg1 + this.msg2;
            var _loc_10:* = new Label();
            new Label().width = 80;
            _loc_10.text = "任务奖励：";
            _loc_10.x = 26;
            _loc_10.color = 16759086;
            _loc_10.stroke = "0x0";
            _loc_10.align = "left";
            _loc_10.isHtml = true;
            this._rewSprite.addChild(_loc_10);
            var _loc_11:* = param1.cfg.taskid;
            var _loc_12:* = this.cfgtask[_loc_11].rewards;
            var _loc_13:int = 0;
            var _loc_14:int = 0;
            while (_loc_14 < _loc_12.length)
            {
                
                if (_loc_12[_loc_14] == null)
                {
                }
                else if (_loc_12[_loc_14].career == 0)
                {
                    if (_loc_12[_loc_14].sex == 2)
                    {
                        _loc_2 = this.cfgitem[_loc_12[_loc_14].itemid];
                        _loc_3 = new FlashItem(_loc_2, 0.6, true, false, null, true, false, true);
                        _loc_3.x = 50;
                        _loc_3.y = _loc_13 * (46 + 3) + 20;
                        this._rewSprite.addChild(_loc_3);
                        this.itemList.push(_loc_3);
                        _loc_4 = new Label();
                        _loc_4.width = 150;
                        _loc_4.text = _loc_2.name + "×" + _loc_12[_loc_14].count;
                        _loc_4.x = 115;
                        _loc_4.y = _loc_13 * (46 + 3) + 16 + 20;
                        _loc_4.color = 16770247;
                        _loc_4.stroke = "0x0";
                        _loc_4.align = "left";
                        _loc_4.isHtml = true;
                        this._rewSprite.addChild(_loc_4);
                        _loc_7 = _loc_7 + 50;
                        _loc_13++;
                    }
                    else if (_loc_12[_loc_14].sex == _loc_6)
                    {
                        _loc_2 = this.cfgitem[_loc_12[_loc_14].itemid];
                        _loc_3 = new FlashItem(_loc_2, 0.6, true, false, null, true, false, true);
                        _loc_3.x = 50;
                        _loc_3.y = _loc_13 * (46 + 3) + 20;
                        this._rewSprite.addChild(_loc_3);
                        this.itemList.push(_loc_3);
                        _loc_4 = new Label();
                        _loc_4.width = 150;
                        _loc_4.text = _loc_2.name + "×" + _loc_12[_loc_14].count;
                        _loc_4.x = 115;
                        _loc_4.y = _loc_13 * (46 + 3) + 16 + 20;
                        _loc_4.color = 16770247;
                        _loc_4.stroke = "0x0";
                        _loc_4.align = "left";
                        _loc_4.isHtml = true;
                        this._rewSprite.addChild(_loc_4);
                        _loc_7 = _loc_7 + 50;
                        _loc_13++;
                    }
                }
                else if (_loc_12[_loc_14].career == _loc_5)
                {
                    if (_loc_12[_loc_14].sex == 2)
                    {
                        _loc_2 = this.cfgitem[_loc_12[_loc_14].itemid];
                        _loc_3 = new FlashItem(_loc_2, 0.6, true, false, null, true, false, true);
                        _loc_3.x = 50;
                        _loc_3.y = _loc_13 * (46 + 3) + 20;
                        this._rewSprite.addChild(_loc_3);
                        this.itemList.push(_loc_3);
                        _loc_4 = new Label();
                        _loc_4.width = 150;
                        _loc_4.text = _loc_2.name + "×" + _loc_12[_loc_14].count;
                        _loc_4.x = 115;
                        _loc_4.y = _loc_13 * (46 + 3) + 16 + 20;
                        _loc_4.color = 16770247;
                        _loc_4.stroke = "0x0";
                        _loc_4.align = "left";
                        _loc_4.isHtml = true;
                        this._rewSprite.addChild(_loc_4);
                        _loc_7 = _loc_7 + 50;
                        _loc_13++;
                    }
                    else if (_loc_12[_loc_14].sex == _loc_6)
                    {
                        _loc_2 = this.cfgitem[_loc_12[_loc_14].itemid];
                        _loc_3 = new FlashItem(_loc_2, 0.6, true, false, null, true, false, true);
                        _loc_3.x = 50;
                        _loc_3.y = _loc_13 * (46 + 3) + 20;
                        this._rewSprite.addChild(_loc_3);
                        this.itemList.push(_loc_3);
                        _loc_4 = new Label();
                        _loc_4.width = 150;
                        _loc_4.text = _loc_2.name + "×" + _loc_12[_loc_14].count;
                        _loc_4.x = 115;
                        _loc_4.y = _loc_13 * (46 + 3) + 16 + 20;
                        _loc_4.color = 16770247;
                        _loc_4.stroke = "0x0";
                        _loc_4.align = "left";
                        _loc_4.isHtml = true;
                        this._rewSprite.addChild(_loc_4);
                        _loc_7 = _loc_7 + 50;
                        _loc_13++;
                    }
                }
                _loc_14++;
            }
            if (param1.cfg.type == 4)
            {
                _loc_16 = new Label();
                _loc_16.isHtml = true;
                _loc_16.width = 150;
                _loc_16.text = MColor.getHMTL("当前星级：" + _loc_8["tid_" + param1.cfg.taskid].star + "星", 68);
                _loc_16.x = 26;
                _loc_16.y = _loc_7;
                this._rewSprite.addChild(_loc_16);
                _loc_17 = new Label();
                _loc_17.isHtml = true;
                _loc_17.width = 150;
                _loc_17.text = MColor.getHMTL("最高星级：10星", 70);
                _loc_17.x = 26;
                _loc_17.y = _loc_16.y + 30;
                this._rewSprite.addChild(_loc_17);
                _loc_7 = _loc_7 + 60;
                this.rcTips.visible = true;
            }
            else
            {
                this.rcTips.visible = false;
            }
            this.line1.y = _loc_7 + this.bHeight;
            if (param1.cfg.tip2 != "")
            {
                _loc_18 = new Label();
                _loc_18.width = 240;
                _loc_18.height = 20;
                _loc_18.text = param1.tip2;
                _loc_18.x = 26;
                _loc_18.y = _loc_7 + 10;
                _loc_18.color = MColor.New50;
                this._rewSprite.addChild(_loc_18);
                _loc_7 = _loc_7 + _loc_18.height;
            }
            if (this.bkImage)
            {
                this.bkImage.width = 290;
                this.bkImage.height = this.bHeight + _loc_7 + 35;
                this.bkImage.visible = true;
            }
            return;
        }// end function

        public function set followMouse(param1:Boolean) : void
        {
            this._followMouse = param1;
            return;
        }// end function

        public function get followMouse() : Boolean
        {
            return this._followMouse;
        }// end function

        private function addreciveHtml(param1:Object, param2:String) : void
        {
            var _loc_3:int = 0;
            var _loc_4:String = null;
            var _loc_5:int = 0;
            var _loc_6:String = null;
            var _loc_7:Array = null;
            var _loc_8:Object = null;
            var _loc_9:int = 0;
            var _loc_10:Object = null;
            var _loc_11:String = null;
            var _loc_12:int = 0;
            var _loc_13:String = null;
            var _loc_14:Object = null;
            if (param2 == "fnpc" && param1.fnpc)
            {
                this.msg1 = "接取：";
                _loc_3 = this.cfgnpcs[param1.fnpc].npcid;
                this.msg2 = "<u>(<A href=\"event:" + param2 + ",\">" + this.cfgNpc[_loc_3].name + "</A>)</u>";
            }
            else if (param2 == "tnpc" && param1.tnpc)
            {
                this.msg1 = "回复：";
                _loc_3 = this.cfgnpcs[param1.tnpc].npcid;
                this.msg2 = "<u>(<A href=\"event:" + param2 + ",\">" + this.cfgNpc[_loc_3].name + "</A>)</u>";
            }
            else if (param2 == "goal")
            {
                _loc_7 = param1.goals;
                _loc_8 = UserData.getData(UserDataType.Task);
                _loc_9 = 0;
                while (_loc_9 < _loc_7.length)
                {
                    
                    _loc_10 = _loc_7[0];
                    _loc_11 = _loc_8["goal_" + _loc_10.goalid];
                    if (!_loc_11)
                    {
                    }
                    else
                    {
                        _loc_11.replace(",", "/");
                        _loc_11 = "<font color=\'#c62442\'>(" + _loc_11 + ")</font>";
                        _loc_12 = _loc_10.goaltype;
                        if (_loc_12 == 2)
                        {
                            _loc_4 = "";
                            if (_loc_10.goalparam == "0")
                            {
                                _loc_4 = "任意怪";
                            }
                            else
                            {
                                _loc_4 = this.cfgMoster[_loc_10.goalparam].name;
                            }
                            this.msg1 = this.goalTypeArr[_loc_10.goaltype] + "：";
                            this.msg2 = "<u><A href=\"event:" + param2 + "," + _loc_10.x + "," + _loc_10.y + "," + _loc_10.stageid + "," + _loc_10.goaltype + "\">" + _loc_4 + "</A></u></font> " + _loc_11.replace(",", "/");
                        }
                        else if (_loc_12 == 3)
                        {
                            _loc_5 = _loc_10.goalparam;
                            _loc_4 = "";
                            if (_loc_5 == 1)
                            {
                                _loc_4 = "强化";
                                this.msg1 = this.goalTypeArr[_loc_10.goaltype] + "：";
                                this.msg2 = "<u><A href=\"event:qianghua\">" + _loc_4 + "</A> </u></font> " + _loc_11.replace(",", "/");
                            }
                            else if (_loc_5 == 2)
                            {
                                _loc_4 = "羽翼进阶";
                            }
                            else if (_loc_5 == 3)
                            {
                                _loc_4 = "坐骑进阶";
                            }
                            else if (_loc_5 == 4)
                            {
                                _loc_4 = "仓库提取";
                                this.msg1 = this.goalTypeArr[_loc_10.goaltype] + "：";
                                this.msg2 = "<u><A href=\"event:" + param2 + ",0," + _loc_10.stageid + "#" + _loc_10.x + "#" + _loc_10.y + ",0," + _loc_10.goaltype + "\">" + _loc_4 + "</A></u></font> " + _loc_11.replace(",", "/");
                            }
                            else if (_loc_5 == 5)
                            {
                                _loc_4 = "合成宝石";
                                this.msg1 = this.goalTypeArr[_loc_10.goaltype] + "：";
                                this.msg2 = "<u><A href=\"event:" + param2 + ",0," + _loc_10.stageid + "#" + _loc_10.x + "#" + _loc_10.y + ",0," + _loc_10.goaltype + "\">" + _loc_4 + "</A></u></font> " + _loc_11.replace(",", "/");
                            }
                            else if (_loc_5 == 350001)
                            {
                                _loc_4 = "兑换倚天";
                                this.msg1 = this.goalTypeArr[_loc_10.goaltype] + "：";
                                this.msg2 = "<u><A href=\"event:" + param2 + ",0," + _loc_10.stageid + "#" + _loc_10.x + "#" + _loc_10.y + ",0," + _loc_10.goaltype + "\">" + _loc_4 + "</A></u></font> " + _loc_11.replace(",", "/");
                            }
                            else if (_loc_5 == 1000)
                            {
                                _loc_4 = "宝石镶嵌";
                                this.msg1 = this.goalTypeArr[_loc_10.goaltype] + "：";
                                this.msg2 = "<u><A href=\"event:" + param2 + ",0," + _loc_10.stageid + "#" + _loc_10.x + "#" + _loc_10.y + ",0," + _loc_10.goaltype + "\">" + _loc_4 + "</A></u></font> " + _loc_11.replace(",", "/");
                            }
                            else if (_loc_5 == 1001)
                            {
                                _loc_4 = "完成押运";
                                this.msg1 = this.goalTypeArr[_loc_10.goaltype] + "：";
                                this.msg2 = "<u><A href=\"event:" + param2 + ",0," + _loc_10.stageid + "#" + _loc_10.x + "#" + _loc_10.y + ",0," + _loc_10.goaltype + "\">" + _loc_4 + "</A></u></font> " + _loc_11.replace(",", "/");
                            }
                            else if (_loc_5 == 1002)
                            {
                                _loc_4 = "守护皇城";
                                this.msg1 = this.goalTypeArr[_loc_10.goaltype] + "：";
                                this.msg2 = "<u><A href=\"event:" + param2 + ",0," + _loc_10.stageid + "#" + _loc_10.x + "#" + _loc_10.y + ",0," + _loc_10.goaltype + "\">" + _loc_4 + "</A></u></font> " + _loc_11.replace(",", "/");
                            }
                            else if (_loc_5 == 1003)
                            {
                                _loc_4 = "微端登陆";
                                this.msg1 = this.goalTypeArr[_loc_10.goaltype] + "：";
                                this.msg2 = "<u><A href=\"event:" + param2 + ",0," + _loc_10.stageid + "#" + _loc_10.x + "#" + _loc_10.y + ",0," + _loc_10.goaltype + "\">" + _loc_4 + "</A></u></font> " + _loc_11.replace(",", "/");
                            }
                            else if (_loc_5 == 722 || _loc_5 == 723)
                            {
                                _loc_4 = "强化装备";
                                this.msg1 = this.goalTypeArr[_loc_10.goaltype] + "：";
                                this.msg2 = "<u><A href=\"event:" + param2 + ",0," + _loc_10.stageid + "#" + _loc_10.x + "#" + _loc_10.y + ",0," + _loc_10.goaltype + "\">" + _loc_4 + "</A></u></font> " + "<font color=\"#FF0000\">" + _loc_11.replace(",", "/");
                            }
                            else if (_loc_5 == 1099)
                            {
                                _loc_4 = "满星降妖伏魔";
                                this.msg1 = this.goalTypeArr[_loc_10.goaltype] + "：";
                                this.msg2 = "<u><A href=\"event:" + param2 + ",0," + _loc_10.stageid + "#" + _loc_10.x + "#" + _loc_10.y + ",0," + _loc_10.goaltype + "\">" + _loc_4 + "</A></u></font> " + "<font color=\"#FF0000\">" + _loc_11.replace(",", "/");
                            }
                            else if (_loc_5 == 1004)
                            {
                                _loc_4 = "装备回收";
                                this.msg1 = this.goalTypeArr[_loc_10.goaltype] + "：";
                                this.msg2 = "<u><A href=\"event:" + param2 + ",0," + _loc_10.stageid + "#" + _loc_10.x + "#" + _loc_10.y + ",0," + _loc_10.goaltype + "\">" + _loc_4 + "</A></u></font> " + "<font color=\"#FF0000\">" + _loc_11.replace(",", "/");
                            }
                        }
                        else if (_loc_12 == 4)
                        {
                            _loc_5 = _loc_10.goalparam;
                            _loc_4 = "";
                            if (_loc_5 == 0)
                            {
                                _loc_4 = "任意草药";
                            }
                            else
                            {
                                _loc_4 = this.cfgMoster[_loc_10.goalparam].name;
                            }
                            this.msg1 = this.goalTypeArr[_loc_10.goaltype] + "：";
                            this.msg2 = "<u><A href=\"event:" + param2 + "," + _loc_10.x + "," + _loc_10.y + "," + _loc_10.stageid + "," + _loc_10.goaltype + "\">" + _loc_4 + "</A></u></font> " + _loc_11.replace(",", "/");
                        }
                        else if (_loc_12 == 5)
                        {
                            _loc_5 = _loc_10.goalparam;
                            _loc_4 = this.cfgMoster[_loc_10.goalparam].name;
                            this.msg1 = this.goalTypeArr[_loc_10.goaltype] + "：";
                            this.msg2 = "<u><A href=\"event:" + param2 + "," + _loc_10.x + "," + _loc_10.y + "," + _loc_10.stageid + "," + _loc_10.goaltype + "\">" + _loc_4 + "</A></u></font> " + _loc_11.replace(",", "/");
                        }
                        else if (_loc_12 == 12 || _loc_12 == 10)
                        {
                            _loc_4 = "";
                            _loc_6 = this.goalTypeArr[_loc_10.goaltype];
                            if (_loc_6.indexOf("{0}") != -1)
                            {
                                _loc_13 = this.cfgitem[_loc_10.goalparam].name;
                                _loc_4 = StringUtil.substitute(_loc_6, _loc_13) + "：";
                            }
                            else
                            {
                                _loc_4 = _loc_6;
                            }
                            this.msg2 = "<u><A href=\"event:" + param2 + "," + _loc_10.x + "," + _loc_10.y + "," + _loc_10.stageid + "," + _loc_10.goaltype + "\">" + _loc_4 + "</A></u></font> " + "<font color=\"#FF0000\">" + _loc_11.replace(",", "/");
                        }
                        else if (_loc_12 == 11 || _loc_12 == 13)
                        {
                            _loc_4 = "";
                            _loc_6 = this.goalTypeArr[_loc_10.goaltype];
                            if (_loc_6.indexOf("{0}") != -1)
                            {
                                _loc_4 = StringUtil.substitute(_loc_6, _loc_10.goalparam) + "：";
                            }
                            else
                            {
                                _loc_4 = _loc_6;
                            }
                            this.msg2 = "<u><A href=\"event:" + param2 + "," + _loc_10.x + "," + _loc_10.y + "," + _loc_10.stageid + "," + _loc_10.goaltype + "\">" + _loc_4 + "</A></u></font> " + "<font color=\"#FF0000\">" + _loc_11.replace(",", "/");
                        }
                        else if (_loc_12 == 16)
                        {
                            this.msg1 = "";
                            _loc_14 = ConfigDictionary.data.maplist;
                            _loc_4 = "";
                            _loc_6 = "击杀{0}";
                            if (_loc_6.indexOf("{0}") != -1)
                            {
                                _loc_4 = StringUtil.substitute(_loc_6, _loc_14[_loc_10.goalparam].name) + "：";
                            }
                            else
                            {
                                _loc_4 = _loc_6;
                            }
                            this.msg2 = "<u><A href=\"event:" + param2 + "," + _loc_10.x + "," + _loc_10.y + "," + _loc_10.stageid + "," + _loc_10.goaltype + "\">" + _loc_4 + "</A></u></font> " + "<font color=\"#FF0000\">" + _loc_11.replace(",", "/");
                        }
                    }
                    _loc_9++;
                }
            }
            return;
        }// end function

    }
}
